package com.eudon.design_pattern.creational.prototype;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author eudon
 * @description 使用示例
 * @date 2025/9/1
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class Use {
    public static void main(String[] args) throws CloneNotSupportedException {
        List<String> addresses = new ArrayList<>();
        addresses.add("北京市丰台区");
        addresses.add("北京市通州区");
        Map<String,String> schools = new HashMap<>();
        schools.put("小学","实验小学");
        schools.put("初中","第一初级中学");
        schools.put("高中","重点高中");
        schools.put("大学","西安邮电大学");
        UserInfo source = new UserInfo();
        source.setAge(18);
        source.setName("eudon");
        source.setAddresses(addresses);
        source.setSchools(schools);

        UserInfo clone = (UserInfo) source.clone();
        source.getSchools().put("大学","清华大学");
        source.getAddresses().remove(1);
        System.out.println(source.getAddresses());
        System.out.println(source.getSchools());

        System.out.println(clone.getAddresses());
        System.out.println(clone.getSchools());
    }
}
